package com.dongdongshop.mp;

import com.dongdongshop.service.SmSServiceI;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RocketMQMessageListener(topic = "sms_code",consumerGroup = "dongdongshopSmS")
public class SmSMQ implements RocketMQListener<String> {

    @Resource
    private SmSServiceI smSServiceI;

    @Override
    public void onMessage(String s) {
        System.out.println("手机号和验证码"+s);
        try {
            String[] split = s.split(",");
            smSServiceI.sendCode(split[0],split[1]);
            System.out.println("消费成功");
        }catch (Exception e){
            System.out.println("消费失败");
        }
    }
}
